package factory_method_pattern.exercise.exercise1;

import java.util.Scanner;

/**
 * 客户端主类
 * @author ricejson
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 支付宝支付方式
        Payment aliPay = new AliPaymentFactory().createPayment();
        Payment wechatPay = new WechatPaymentFactory().createPayment();
        Payment bankPay = new BankPaymentFactory().createPayment();
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            String payStr = line.split(" ")[0];
            String payMountStr = line.split(" ")[1];
            double payMount = Double.parseDouble(payMountStr);
            switch (payStr) {
                case "Alipay": {
                    aliPay.pay(payMount);
                    break;
                }
                case "WeChatPay": {
                    wechatPay.pay(payMount);
                    break;
                }
                case "BankCard": {
                    bankPay.pay(payMount);
                    break;
                }
                default: {
                    System.out.println("输入不合法");
                    return;
                }
            }
        }
    }
}
